#include "overscene.h"

OverScene::OverScene()
{
    QPushButton* button1 = new QPushButton("回到主菜单");
    QPushButton* button2 = new QPushButton("再来一局");
    QPushButton* button3 = new QPushButton("退出游戏");
    button1->setStyleSheet("height:64px;width:256px");
    button2->setStyleSheet("height:64px;width:256px");
    button3->setStyleSheet("height:64px;width:256px");

    connect(button1, &QPushButton::clicked, [&]() {
        MainWindow *mainWindow=(MainWindow *)(getView()->parent()->parent());
        mainWindow->setScene(mainWindow->menuScene);
    });

    connect(button2, &QPushButton::clicked, [&]() {
        MainWindow *mainWindow=(MainWindow *)(getView()->parent()->parent());
        mainWindow->setScene(mainWindow->combatScene);
    });

    connect(button3, &QPushButton::clicked, [&]() {
        MainWindow *mainWindow=(MainWindow *)(getView()->parent()->parent());
        mainWindow->close();
    });
    label=new QLabel;

    btn1 = addWidget(button1);
    btn2 = addWidget(button2);
    btn3 = addWidget(button3);
}


void OverScene::run(){

}

void OverScene::init(){
     //QGraphicsView *view=getView();
     int centerX = width() / 2;
     int centerY = height() / 2;

     btn1->setPos(centerX - btn1->size().width()/2, centerY + btn1->size().height()+30 );
     btn2->setPos(centerX - btn2->size().width()/2, centerY);
     btn3->setPos(centerX - btn3->size().width()/2, centerY - btn3->size().height()-30);



     label->setGeometry(centerX-btn1->size().width()/2,centerY-2*btn1->size().height()-60,256,64);

     label->setStyleSheet("background:transparent");
     label->setAlignment(Qt::AlignCenter);
     QFont ft;
     ft.setPointSize(45);
     label->setFont(ft);

     if(MainWindow::scoreP1>MainWindow::scoreP2){
         qDebug()<<"P1 win!";
         label->setText("P1 win!");
     }else if((MainWindow::scoreP1==MainWindow::scoreP2)){
         qDebug()<<"平局!";
         label->setText("平局");
     }else if(MainWindow::scoreP1<MainWindow::scoreP2){
         qDebug()<<"P2 win!!";
         label->setText("P2 win");
     }
     addWidget(label);

}












